package com.it.spring6.iocxml;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestUser {

    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");

        User user1 = (User) context.getBean("user");
        System.out.println("根据id获取bean" + user1);

        User user2 = context.getBean(User.class);
        System.out.println("根据类型" + user2);

        User user3 = context.getBean("user", User.class);
        System.out.println("3" + user3);
        System.out.println("--------------");
        new User(){
            @Override
            public void run() {
                super.run();
            }
        }.run();
    }
}
